/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package DAL;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;

/**
 *
 * @author roberto
 */
public class Conexion {
    private Connection cnn;
    
    public void conectar() {
        try {
            Class.forName("com.mysq.jdbc.Driver");
            
        } catch (ClassNotFoundException e) {
            
        }
        
        try {
            cnn = DriverManager.getConnection("jdbc:mysql://localhost/boliche","root","");
             System.out.println("Conectado a la Base de Datos");
        }
        
        catch(SQLException e) {
           JOptionPane.showMessageDialog(null,"No conectado.intenta denuevo "+e);                 
        }
    }

    public ResultSet consulta(String consulta)throws SQLException{
        Statement st=cnn.createStatement();
        ResultSet rs=st.executeQuery(consulta);  
        
        return rs;
    }
    
    public void modifica(String consulta)throws SQLException{
        Statement st=cnn.createStatement();
        st.executeUpdate(consulta);
    }
    
    public Conexion() {
        conectar();
    }
    
}
